home *** CD-ROM | disk | FTP | other *** search
- walking = false;
- parrying = false;
- slashing = false;
- jumping = false;
- speed = 0;
- turbo = 0;
- turnTo = "";
- stop();
- this.onEnterFrame = function()
- {
- if(!init)
- {
- return undefined;
- }
- onWalk();
- onRecieveHit();
- doCalcs();
- if(!walking && !slashing && !jumping && !parrying && !turning && !recieving && !dead)
- {
- unwalk();
- gotoAndStop("stand");
- }
- };
- doCalcs = function()
- {
- if(!(walking || slashing || jumping || parrying || turning || recieving))
- {
- ki += regen_rate;
- }
- if(ki > total_ki)
- {
- ki = total_ki;
- }
- if(hp > total_hp)
- {
- hp = total_hp;
- }
- if(ki < 0)
- {
- ki = 0;
- }
- if(hp < 0)
- {
- hp = 0;
- }
- pic.bars.hp._xscale = Math.ceil(hp / total_hp * 100);
- pic.bars.ki._xscale = Math.ceil(ki / total_ki * 100);
- };
- if(!init)
- {
- pic = _root.pic_hitomi;
- side = "R";
- orig_scale = _xscale;
- init = true;
- total_hp = 100;
- hp = total_hp;
- total_ki = 100;
- ki = total_ki;
- regen_rate = 1;
- last_attack_types = [];
- }
- getDirection = function()
- {
- if(orig_scale == _xscale)
- {
- return 1;
- }
- return -1;
- };
- attack = function(type, ki_cost)
- {
- if(jumping || slashing || recieving || dead)
- {
- return undefined;
- }
- if(turning)
- {
- completeTurn();
- }
- this.ki_cost = ki_cost;
- m = 1;
- if(type == last_attack_types[0])
- {
- m = 2;
- if(type == last_attack_types[1])
- {
- m = 3;
- }
- }
- last_attack_types.unshift(type);
- if(last_attack_types.length > 5)
- {
- last_attack_types.pop();
- }
- if(ki_cost * m > ki)
- {
- return undefined;
- }
- turning = false;
- slashing = true;
- waswalking = walking;
- walking = false;
- speed = 0;
- delete this.onWalk;
- gotoAndPlay(type);
- };
- unattack = function()
- {
- if(slashing)
- {
- ki -= ki_cost * m;
- }
- slashing = false;
- if(waswalking || Key.isDown(39) && side == "R" || Key.isDown(37) && side == "L")
- {
- waswalking = false;
- walking = false;
- walk();
- }
- };
- slash1 = function()
- {
- attack("slash1",4);
- };
- slash2 = function()
- {
- attack("slash2",5);
- };
- headslash = function()
- {
- attack("headslash",15);
- };
- headslash2 = function()
- {
- attack("headslash2",6);
- };
- jump = function()
- {
- if(!jumping && !recieving && !slashing && !dead)
- {
- jumping = true;
- if(walking)
- {
- unwalk();
- }
- turning = false;
- slashing = false;
- gotoAndStop("jump");
- play();
- }
- };
- backflip = function()
- {
- if(!jumping && !recieving && !dead)
- {
- if(walking)
- {
- turning = false;
- walking = false;
- delete this.onWalk;
- speed = 0;
- }
- turning = false;
- slashing = false;
- gotoAndStop("backflip");
- play();
- }
- };
- frontflip = function()
- {
- if(!jumping && !recieving && !slashing && !dead)
- {
- jumping = true;
- waswalking = walking;
- if(walking)
- {
- turning = false;
- walking = false;
- delete this.onWalk;
- speed = 0;
- }
- slashing = false;
- if(!turning)
- {
- turning = false;
- gotoAndStop("frontflip");
- play();
- }
- else
- {
- turning = false;
- gotoAndStop("backflip");
- play();
- }
- }
- };
- right = function()
- {
- turn("R");
- };
- left = function()
- {
- turn("L");
- };
- turn = function(toside)
- {
- if(slashing || recieving || dead)
- {
- return undefined;
- }
- if(side != toside)
- {
- if(!walking && !jumping && !turning && turnTo == "")
- {
- turnTo = toside;
- turning = true;
- walking = false;
- jumping = false;
- parrying = false;
- speed = 0;
- gotoAndStop("turn");
- play();
- }
- }
- else
- {
- turning = false;
- walk();
- }
- };
- completeTurn = function()
- {
- side = turnTo;
- turning = false;
- if(turnTo == "L")
- {
- _xscale = - orig_scale;
- }
- else
- {
- _xscale = orig_scale;
- }
- };
- turnTo = "";
- walk = function()
- {
- if(walking || slashing || jumping || parrying || turning || recieving || dead)
- {
- return undefined;
- }
- walking = true;
- gotoAndStop("walk");
- play();
- this.count = 0;
- this.onWalk = function()
- {
- count++;
- walking = true;
- if(side == "R")
- {
- speed = 2 + turbo;
- }
- else
- {
- speed = - (2 + turbo);
- }
- };
- };
- unwalk = function()
- {
- if(walking)
- {
- delete this.onWalk;
- turning = false;
- walking = false;
- speed = 0;
- }
- if(slashing)
- {
- turning = false;
- walking = false;
- speed = 0;
- }
- if(waswalking)
- {
- waswalking = false;
- }
- };
- parry = function()
- {
- if(!parrying && !slashing && !jumping && !dead)
- {
- turning = false;
- jumping = false;
- parrying = true;
- delete this.onWalk;
- walking = false;
- speed = 0;
- gotoAndStop("parry");
- play();
- }
- };
- unparry = function()
- {
- if(parrying)
- {
- delete this.onWalk;
- turning = false;
- parrying = false;
- jumping = false;
- slashing = false;
- recieving = false;
- walking = false;
- speed = 0;
- gotoAndStop("unparry");
- play();
- }
- };
- recieveHit = function(hit_by)
- {
- if(recieving)
- {
- return undefined;
- }
- if(parrying)
- {
- if(getDirection() == hit_by.getDirection())
- {
- trace("defense!");
- return undefined;
- }
- }
- var _loc3_ = hit_by.damage;
- fall_distance = hit_by.pushfactor;
- hp -= _loc3_;
- onRecieveHit = function()
- {
- fall_distance--;
- if(fall_distance < 1)
- {
- delete this.onRecieveHit;
- fall_distance = 0;
- speed = 0;
- return undefined;
- }
- _root.pan(-1 * hit_by.getDirection() * fall_distance);
- };
- recieving = true;
- waswalking = walking;
- gotoAndStop("recievehit");
- play();
- };
- unRecieveHit = function()
- {
- if(hp < 1)
- {
- dead = true;
- delete this.onEnterFrame;
- return undefined;
- }
- recieving = false;
- turning = false;
- slashing = false;
- jumping = false;
- parrying = false;
- walking = false;
- if(waswalking || Key.isDown(39) && side == "R" || Key.isDown(37) && side == "L")
- {
- waswalking = false;
- walking = false;
- walk();
- }
- else
- {
- gotoAndStop("stand");
- }
- };
- playSound = function(ids)
- {
- _root.sounds.playSound(ids);
- };
-